home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1263 / sxtnview.doc < prev    next >
Text File  |  1997-04-18  |  17KB  |  442 lines

  1.  
  2.  
  3.  
  4.  
  5.          SXTNVIEW.DOC
  6.  
  7.          SXTNVIEW - SXTN Database Viewer Sample Application
  8.  
  9.          The  SXTNVIEW program  is intended as  a sample  application to
  10.          demonstrate  the use of  the DLL interface  functions to access
  11.          the  SXT  databases.  Each  SXT  windows  version provides  its
  12.          specific  DLL (CFTN16.DLL,  CSTN16.DLL, ...) together  with the
  13.          necessary C/C++  header file (CFTNWIN.H, CSTNWIN.H, ...) and an
  14.          import library (CFTN16.LIB, CSTN16.LIB, ...) that can be linked
  15.          to your programs. SXTNVIEW is a very simple application written
  16.          in  Visual Basic with  complete source  code included. SXTNVIEW
  17.          works with all SXT DLL's and demonstrates the access to all SXT
  18.          database types.
  19.  
  20.          To  run SXTNVIEW, the Visual  Basic runtime library VB40016.DLL
  21.          (not included in this package) installed in the \windows\system
  22.          directory  is required. It  is also  necessary to  copy the SXT
  23.          DLL's to the \windows\system directory.
  24.  
  25.          After starting SXTNVIEW you have to select the SXT program type
  26.          and  the database from  the file  dialog box.  Select one *.dbf
  27.          file  that belongs to the project you  want to view. After that
  28.          you  can  view  in two  list  boxes  the  items (functions/data
  29.          types), either  all or only the defined ones, and the filenames
  30.          by pressing  push buttons next to these list boxes. By a double
  31.          click  on an item you get its  location (filename, line number)
  32.          where  it  is defined/  first found.  By  a double  click  on a
  33.          filename you  get a list of all defined items in that file. You
  34.          can  also directly type  the name of  an item  into the 'Search
  35.          for'  text box and start  a search with the  push button. If an
  36.          item  name is in the  search box you can  press the 'Get Called
  37.          Item'  button to retrieve all  items which are  called from the
  38.          item.
  39.  
  40.          Any running  action can be safely stopped by pressing the 'Stop
  41.          Action' button. The system returns to default state.
  42.  
  43.  
  44.          DLL INTERFACE FUNCTIONS
  45.  
  46.          The  following description  is given  for  the CFT  version but
  47.          applies in the same way to all other SXT programs. The user who
  48.          calls  one of these  functions has  to ensure  that the calling
  49.          parameters  are large  enough to hold  the resulting  value. In
  50.          general, the strings should be a minimum of 300 characters long
  51.          (char location[300], char name[300], ...).
  52.  
  53.          Some functionality  is split into a pair of two closely related
  54.          functions,  like cftnGetFirstName()  and cftnGetNextName(). The
  55.          user  has to ensure that  they are called in  a direct sequence
  56.          and  that  there are  no  intermediate calls,  also  from other
  57.          applications.  Otherwise  the results  will  be  incorrect. The
  58.          reason  for the split  of the functionality  is that  it is not
  59.          possible to  determine the amount of memory to hold the results
  60.          of  the function call  in advance  by the  calling function. It
  61.          would have  been possible to grow the memory dynamically during
  62.          search operation by the DLL, return a pointer to the memory and
  63.  
  64.                                         1
  65.  
  66.  
  67.  
  68.          leave  it to the application  to free it after  use. This would
  69.          work  with C  but not  with Visual  Basic or  application macro
  70.          languages like Word Basic and Visual Basic for Applications.
  71.  
  72.          The  return values of all DLL functions  are 101 if successful,
  73.          all other  values mean that something went wrong (e.g. database
  74.          not found, database is not a SXT database, item does not exist,
  75.          out of memory, ...).
  76.  
  77.          Following is a description of the DLL-functions:
  78.  
  79.          LONG  WINAPI cftnGetLocation(LPSTR  dbfname, LPSTR  name, LPSTR
  80.          location);
  81.          Get the location of a specific item, if the return value is 101
  82.          a location for item was found.
  83.            dbfname   the database name
  84.            name      the name of the item
  85.            location  contains     a    string    with    the    location
  86.          (filename<space>line number) of the item
  87.  
  88.          LONG WINAPI cftnGetFirstName(LPSTR dbfname, LPSTR name);
  89.          Get  the  first item  from the  database, must  be  called once
  90.          before cftnGetNextName.
  91.            dbfname   the database name
  92.            name      contains a string with the item name
  93.  
  94.          LONG WINAPI cftnGetNextName(LPSTR dbfname, LPSTR name);
  95.          Get  the  next item  from the  database, must  be  called after
  96.          cftnGetFirstName, as long as the return value is 101 a new name
  97.          is retrieved.
  98.            dbfname   the database name
  99.            name      contains a string with the item name
  100.  
  101.          LONG WINAPI cftnGetFirstDefName(LPSTR dbfname, LPSTR name);
  102.          Get  the first defined item  from the database,  must be called
  103.          once before cftnGetNextDefName.
  104.            dbfname   the database name
  105.            name      contains a string with the defined item name
  106.  
  107.          LONG WINAPI cftnGetNextDefName(LPSTR dbfname, LPSTR name);
  108.          Get  the next defined  item from  the database,  must be called
  109.          after cftnGetFirstDefName, as long as the return value is 101 a
  110.          new name is retrieved.
  111.            dbfname   the database name
  112.            name      contains a string with the defined item name
  113.  
  114.          LONG WINAPI cftnGetFirstCalledItem(LPSTR dbfname, LPSTR caller,
  115.          LPSTR calleditem, LPSTR location);
  116.          Get the  first called item of caller from the database, must be
  117.          called once before cftnGetNextCalledItem.
  118.            dbfname   the database name
  119.            caller      contains a string with the name of the caller
  120.            calleditem    contains a string with the first called item
  121.            location      contains    a   string    with   the   location
  122.          (filename<space>line number) of the item
  123.  
  124.  
  125.  
  126.  
  127.                                         2
  128.  
  129.  
  130.  
  131.          LONG  WINAPI cftnGetNextCalledItem(LPSTR dbfname, LPSTR caller,
  132.          LPSTR calleditem, LPSTR location);
  133.          Get  the next called item of caller  from the database, must be
  134.          called  after  cftnGetFirstCalledItem, as  long  as  the return
  135.          value is 101 a new called item is retrieved.
  136.            dbfname   the database name
  137.            caller      contains a string with the name of the caller
  138.            calleditem    contains a string with the first called item
  139.            location      contains    a   string    with   the   location
  140.          (filename<space>line number) of the item
  141.  
  142.          LONG WINAPI cftnGetFirstFile(LPSTR dbfname, LPSTR filename);
  143.          Get  the  first file  from the  database, must  be  called once
  144.          before cftnGetFirstFile.
  145.            dbfname   the database name
  146.            name      contains a string with the filename
  147.  
  148.          LONG WINAPI cftnGetNextFile(LPSTR dbfname, LPSTR filename);
  149.          Get  the  next file  from the  database, must  be  called after
  150.          cftnGetFirstFile, as long as the return value is 101 a new file
  151.          is retrieved.
  152.            dbfname   the database name
  153.            name      contains a string with the filename
  154.  
  155.  
  156.          THE VISUAL BASIC EXAMPLE 'SXTNVIEW'
  157.  
  158.          Following  is  a short,  incomplete extract  from  the SXTNVIEW
  159.          Visual Basic source code to show some implementation details.
  160.  
  161.          1.  DLL-FUNCTION DECLARATION
  162.          The DLL-functions have to be declared in the following way:
  163.  
  164.          Declare   Function  cftnGetLocation   Lib  "cftn16.dll"  (ByVal
  165.              dbfname$, ByVal searchname$, ByVal location$) As Long
  166.          Declare   Function  cftnGetFirstName  Lib  "cftn16.dll"  (ByVal
  167.              dbfname$, ByVal location$) As Long
  168.          Declare   Function  cftnGetNextName   Lib  "cftn16.dll"  (ByVal
  169.              dbfname$, ByVal location$) As Long
  170.          Declare  Function  cftnGetFirstDefName Lib  "cftn16.dll" (ByVal
  171.              dbfname$, ByVal location$) As Long
  172.          Declare  Function  cftnGetNextDefName  Lib  "cftn16.dll" (ByVal
  173.              dbfname$, ByVal location$) As Long
  174.          Declare Function cftnGetFirstCalledItem Lib "cftn16.dll" (ByVal
  175.              dbfname$,   ByVal   caller$,   ByVal   calleditem$,   ByVal
  176.              location$) As Long
  177.          Declare  Function cftnGetNextCalledItem Lib "cftn16.dll" (ByVal
  178.              dbfname$,   ByVal   caller$,   ByVal   calleditem$,   ByVal
  179.              location$) As Long
  180.          Declare   Function  cftnGetFirstFile  Lib  "cftn16.dll"  (ByVal
  181.              dbfname$, ByVal location$) As Long
  182.          Declare   Function  cftnGetNextFile   Lib  "cftn16.dll"  (ByVal
  183.              dbfname$, ByVal location$) As Long
  184.          (similar for the other DLL's)
  185.  
  186.          2.  CALLING THE RIGHT SXT FUNCTION
  187.          The  SXTNVIEW functions call for  every DLL-related function an
  188.          intermediate  function  where, according  to  the  selected SXT
  189.  
  190.                                         3
  191.  
  192.  
  193.  
  194.          type,  the right  DLL-function is  called. This  simplifies the
  195.          source code.
  196.  
  197.          Function sxtnGetFirstName (dbfname$, location$) As Long
  198.            If option1.Value = True Then
  199.              sxtnGetFirstName = cftnGetFirstName(dbfname, location)
  200.            ElseIf option2.Value = True Then
  201.              sxtnGetFirstName = cstnGetFirstName(dbfname, location)
  202.            ElseIf option3.Value = True Then
  203.              sxtnGetFirstName = dftnGetFirstName(dbfname, location)
  204.            ElseIf option4.Value = True Then
  205.              sxtnGetFirstName = fftnGetFirstName(dbfname, location)
  206.            ElseIf option5.Value = True Then
  207.              sxtnGetFirstName = lftnGetFirstName(dbfname, location)
  208.            End If
  209.          End Function
  210.          (similar for the other SXT DLL functions)
  211.  
  212.          3.  FUNCTION TO RETRIEVE THE LOCATION OF A SPECIFIC ITEM
  213.          Sub Command2_Click ()
  214.            Dim dbfname As String
  215.            Dim searchname As String
  216.            Dim result As String
  217.            result = String$(300, 0)
  218.            dbfname = label1.Caption
  219.            searchname = text1.Text
  220.            If  Left(dbfname$, 1)  <> "" And  Left(searchname$, 1)  <> ""
  221.          Then
  222.              retval = sxtnGetLocation(dbfname$, searchname$, result$)
  223.              label7.Caption = result$
  224.            End If
  225.          End Sub
  226.  
  227.          4.  FUNCTION TO RETRIEVE ALL FILES
  228.          Sub Command3_Click ()
  229.            Dim string1 As String
  230.            Dim result As String
  231.            string1$ = label1.Caption
  232.            result = String$(300, 0)
  233.            list2.Clear
  234.            If Left(string1$, 1) <> "" Then
  235.              retval = sxtnGetFirstFile(string1$, result$)
  236.              If retval = 101 Then
  237.                list2.AddItem result$
  238.                Do
  239.                  retval = sxtnGetNextFile(string1$, result$)
  240.                  If retval = 101 Then
  241.                    list2.AddItem result$
  242.                  Else
  243.                    Exit Do
  244.                  End If
  245.                Loop While retval = 101
  246.              End If
  247.            End If
  248.            label6.Caption = Str$(list2.ListCount) + " files"
  249.          End Sub
  250.  
  251.  
  252.  
  253.                                         4
  254.  
  255.  
  256.  
  257.          5.  FUNCTION TO RETRIEVE ALL ITEMS
  258.          Sub Command4_Click ()
  259.            Dim dbfname As String
  260.            Dim result As String
  261.            dbfname$ = label1.Caption
  262.            result = String$(300, 0)
  263.            list1.Clear
  264.            If Left(dbfname$, 1) <> "" Then
  265.              retval = sxtnGetFirstName(dbfname$, result$)
  266.              If retval = 101 Then
  267.                list1.AddItem result$
  268.                Do
  269.                  retval = sxtnGetNextName(dbfname$, result$)
  270.                  If retval = 101 Then
  271.                    list1.AddItem result$
  272.                  Else
  273.                    Exit Do
  274.                  End If
  275.                Loop While retval = 101
  276.              End If
  277.            End If
  278.            label5.Caption = Str$(list1.ListCount) + " items"
  279.          End Sub
  280.  
  281.          6.  FUNCTION TO RETRIEVE ALL DEFINED ITEMS
  282.          Sub Command5_Click ()
  283.            Dim dbfname As String
  284.            Dim result As String
  285.            dbfname$ = label1.Caption
  286.            result = String$(300, 0)
  287.            list1.Clear
  288.            If Left(dbfname$, 1) <> "" Then
  289.              retval = sxtnGetFirstDefName(dbfname$, result$)
  290.              If retval = 101 Then
  291.                list1.AddItem result$
  292.                Do
  293.                  retval = sxtnGetNextDefName(dbfname$, result$)
  294.                  If retval = 101 Then
  295.                    list1.AddItem result$
  296.                  Else
  297.                    Exit Do
  298.                  End If
  299.                Loop While retval = 101
  300.              End If
  301.            End If
  302.            label5.Caption = Str$(list1.ListCount) + " defined items"
  303.          End Sub
  304.  
  305.          7.  FUNCTION TO RETRIEVE ALL ITEMS DEFINED IN A SPECIFIC FILE
  306.          Sub List2_DblClick ()
  307.            Dim dbfname As String
  308.            Dim searchname As String
  309.            Dim result As String
  310.            dbfname$ = label1.Caption
  311.            result = String$(300, 0)
  312.            FileName = list2.List(list2.ListIndex)
  313.            list1.Clear
  314.            If Left(dbfname$, 1) <> "" Then
  315.  
  316.                                         5
  317.  
  318.  
  319.  
  320.              retval = sxtnGetFirstDefName(dbfname$, result$)
  321.              If retval = 101 Then
  322.                searchname  = Left$(result, InStr(1, result, Chr$(0),1) -
  323.          1)
  324.                result = String$(300, 0)
  325.                retval = sxtnGetLocation(dbfname$, searchname$, result$)
  326.                If retval = 101 Then
  327.                  If InStr(1, result, FileName, 1) Then
  328.                    list1.AddItem searchname$
  329.                  End If
  330.                End If
  331.              End If
  332.              Do
  333.                retval = sxtnGetNextDefName(dbfname$, result$)
  334.                If retval = 101 Then
  335.                  searchname = Left$(result, InStr(1, result, Chr$(0),1)-
  336.          1)
  337.                  result = String$(300, 0)
  338.                  retval    =    sxtnGetLocation(dbfname$,   searchname$,
  339.          result$)
  340.                  If retval = 101 Then
  341.                    If InStr(1, result, FileName, 1) Then
  342.                      list1.AddItem searchname$
  343.                    End If
  344.                  End If
  345.                Else
  346.                  Exit Do
  347.                End If
  348.              Loop While retval = 101
  349.            End If
  350.            label5.Caption = Str$(list1.ListCount) + " defined items in "
  351.          + FileName
  352.          End Sub
  353.  
  354.          8.  FUNCTION TO RETRIEVE ALL CALLED ITEMS OF A SPECIFIC ITEM
  355.          Sub Command6_Click ()
  356.            Dim dbfname As String
  357.            Dim caller As String
  358.            Dim location As String
  359.            Dim calleditem As String
  360.            dbfname$ = label1.Caption
  361.            calleditem = String$(300, 0)
  362.            location = String$(300, 0)
  363.            caller = text1.Text
  364.            list1.Clear
  365.            If Left(dbfname$, 1) <> "" Then
  366.              retval    =    sxtnGetFirstCalledItem(dbfname$,    caller$,
  367.          calleditem$, location$)
  368.              If retval = 101 Then
  369.                list1.AddItem calleditem$
  370.                Do
  371.                  retval   =   sxtnGetNextCalledItem(dbfname$,   caller$,
  372.          calleditem$, location$)
  373.                  If retval = 101 Then
  374.                    list1.AddItem calleditem$
  375.                  Else
  376.                    Exit Do
  377.                  End If
  378.  
  379.                                         6
  380.  
  381.  
  382.  
  383.                Loop While retval = 101
  384.              End If
  385.            End If
  386.            label5.Caption = Str$(list1.ListCount) + " called items"
  387.          End Sub
  388.  
  389.  
  390.          FURTHER DEVELOPMENT
  391.  
  392.          The  above example  demonstrates the  capabilities of  the SXT-
  393.          DLL's. They can be called from any Windows application, e.g. MS
  394.          Word  for Windows, MS  Excel, MS Access,  CodeWright Editor, or
  395.          from user developed applications.
  396.  
  397.  
  398.  
  399.          Copyright (C) Juergen Mueller (J.M.) 1988-1996.
  400.          All rights reserved world-wide.
  401.  
  402.          SXT (TM) SOFTWARE EXPLORATION TOOLS
  403.          SXTWIN (TM) SOFTWARE EXPLORATION TOOLS for Windows
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.                                         7